<template>
    <div id="home">
      <div class="aside-col">
        <el-menu class="menu" :default-active="$route.path" router :collapse="isCollapse" background-color="#000" text-color="#fff" active-text-color="#ffd04b">
          <el-menu-item @click="changeCollapse" index="/Home">
            <i><img src="../assets/icons/catalog.png" width="15px" height="15px" /></i>
          </el-menu-item>
          <el-menu-item index="/Home/homepage">
            <i class="el-icon-menu"></i>
            <span slot="title">管理员</span>
          </el-menu-item>
          <el-menu-item index="/Home/modification">
            <i class="el-icon-tickets"></i>
            <span slot="title">发布</span>
          </el-menu-item>
          <el-menu-item index="/Home/collectionChannel">
            <i class="el-icon-edit"></i>
            <span slot="title">管理文章</span>
          </el-menu-item>
          <el-menu-item index="/Home/comment">
            <i class="el-icon-edit"></i>
            <span slot="title">管理评论</span>
          </el-menu-item>
          <el-menu-item index="/Home/message">
            <i class="el-icon-edit"></i>
            <span slot="title">管理留言</span>
          </el-menu-item>
        </el-menu>
      </div>
        <div class="main-col">
          <router-view></router-view>
        </div>
    </div>
</template>

<script>
export default {
    name: "Home",
  data () {
      return{
        isCollapse:false
      }
  },
  methods:{
      changeCollapse () {
        var mainCol = document.getElementsByClassName('main-col')[0];
        this.isCollapse = !this.isCollapse
        if(this.isCollapse) {
          mainCol.style.left = '90px';
          mainCol.style.width='calc(100% - 110px)'
        }
        else {
          mainCol.style.left = '220px';
          mainCol.style.width = 'calc(100% - 240px)'
        }
      }
  }
}
</script>

<style scoped lang="less">
.menu{
  height: 100vh;
}
.el-menu-item{
  text-align: left;
  border-bottom: 1px solid gray;
}
.aside-col{
  // display: inline-block;
  float: left;
  width: 210px;
  position: fixed;
}
.main-col{
  // position: fixed;
  left: 330px;
  display: inline-block;
  width: calc(100% - 240px);
  margin-left: 220px;
}
</style>
